package com.linkage.jz.bankruptcy.bean.Vote;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.linkage.jz.bankruptcy.R;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author AFAP
 * 表决
 */
public class ProVote implements Serializable {

    public final static Map<Integer, String> TYPES = new HashMap();
    public final static Map<Boolean, String> COURTHOLDINGs = new HashMap();
    public final static Map<Integer, String> COURTHOLDINGRESULTS = new HashMap();
    public final static Map<Integer, String> STATUS = new HashMap();
    public final static Map<Integer, Integer> STATUSIMGS = new HashMap();

    public final static int STATUS_WFC = 0;
    public final static int STATUS_WKS = 1;
    public final static int STATUS_JXZ = 2;
    public final static int STATUS_YJS = 3;
    public final static int STATUS_YCX = 4;
    public final static int STATUS_YTG = 5;
    public final static int STATUS_WTG = 6;
    public final static int STATUS_YSC = 7;


    static {
        TYPES.put(1, "债权人会议表决");
        TYPES.put(2, "债权人委员会表决");

        COURTHOLDINGs.put(true, "表决结果需要法院裁定");
        COURTHOLDINGs.put(false, "表决结果不需要法院裁定");

        COURTHOLDINGRESULTS.put(1, "裁定认可");
        COURTHOLDINGRESULTS.put(2, "裁定不认可");
        COURTHOLDINGRESULTS.put(3, "裁定通过");


        STATUS.put(0, "未发出");
        STATUS.put(1, "未开始");
        STATUS.put(2, "进行中");
        STATUS.put(3, "已结束");
        STATUS.put(4, "已撤销");
        STATUS.put(5, "已通过");
        STATUS.put(6, "未通过");
        STATUS.put(7, "已删除");

        STATUSIMGS.put(0, R.drawable.vote_status_wfc);
        STATUSIMGS.put(1, R.drawable.vote_status_wks);
        STATUSIMGS.put(2, R.drawable.vote_status_jxz);
        STATUSIMGS.put(3, R.drawable.vote_status_yjs);
        STATUSIMGS.put(4, R.drawable.vote_status_ycx);
        STATUSIMGS.put(5, R.drawable.vote_status_ytg);
        STATUSIMGS.put(6, R.drawable.vote_status_wtg);
        STATUSIMGS.put(7, R.drawable.vote_status_ysc);
    }

    private String id; // 表决项id
    private String bankruptcyProjectId;//projectId
    private String creditorId;

    public boolean getNoGroupData() {
        return noGroupData;
    }

    public void setNoGroupData(boolean noGroupData) {
        this.noGroupData = noGroupData;
    }

    private boolean  noGroupData;

    public Boolean getDefaultAgreed() {
        return defaultAgreed;
    }

    public void setDefaultAgreed(Boolean defaultAgreed) {
        this.defaultAgreed = defaultAgreed;
    }

    private Boolean defaultAgreed;
    private boolean courtHolding; // 表决结果是否需要法院裁定,结果为true或false。注意：如果出现为null的情况当作false处理，即非true即为false
    private int type; // 表决类型	 1-债权人会议表决,2-债权人委员会表决
    private String title; // 标题
    private String content;//内容
    private long startTime; // 开始时间
    private long endTime; // 结束时间
    private String ruleName;//表决规则名
    private String ruleExplain;//表决规则说明
    private String projectColumnPermission; // 项目栏目操作权限
    private int projectRole; // 项目角色
    private boolean opManagementMembers; // 添加和删除管理人组成员
    private boolean opOtherMembers; // 添加和删除其他成员
    private boolean groupLeader; // 是否组长
    private boolean contactCreditor; // 联系沟通债权人
    private int status; // 表决状态 0, 未发出 1, 未开始 2, 进行中  3, 已结束 4, 已撤销 5, 已通过  6, 未通过 7, 已删除
    private String cancel;//撤销时的撤销说明
    private int courtHoldingResult; // 法院裁定结果 1-裁定认可 2-裁定不认可 3-裁定通过
    private int meeting;//如果该数字与total相等，则说明已参会，否则为未参会
    private int vote;//如果该数字与total相等，则说明已表决，否则为未表决
    private int total;//总分组数，即当前债权人在该表决项在几个分组中
    private boolean grouped;//是否分组，以此字段为判断条件
    private int memberTotal;//grouped=false未分组时 表决总人员数

    //以下四个参数是后台返回 用于页面按钮显示和不显示用
    private int joinMeeting;//参会按钮 0不显示 1显示
    private int meetingVote;//参会表决按钮 0不显示 1显示
    private int quitMeeting;//退出参会按钮 0不显示 1显示
    private int doVote;//表决按钮 0不显示 1显示

    private Auth auth;
    private String resultId;//resultId !=null && resultStatus==1显示
    private int resultStatus;//0 无表决结果 1有表决结果
    private List<ProVoteFile> files;
    private List<ProVoteVoterGroup> groups;
    private List<ProVoteVoterMyGroup> groupInfo;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBankruptcyProjectId() {
        return bankruptcyProjectId;
    }

    public void setBankruptcyProjectId(String bankruptcyProjectId) {
        this.bankruptcyProjectId = bankruptcyProjectId;
    }

    public String getCreditorId() {
        return creditorId;
    }

    public void setCreditorId(String creditorId) {
        this.creditorId = creditorId;
    }

    public boolean isCourtHolding() {
        return courtHolding;
    }

    public void setCourtHolding(boolean courtHolding) {
        this.courtHolding = courtHolding;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public String getRuleName() {
        return ruleName;
    }

    public void setRuleName(String ruleName) {
        this.ruleName = ruleName;
    }

    public String getRuleExplain() {
        return ruleExplain;
    }

    public void setRuleExplain(String ruleExplain) {
        this.ruleExplain = ruleExplain;
    }

    public String getProjectColumnPermission() {
        return projectColumnPermission;
    }

    public void setProjectColumnPermission(String projectColumnPermission) {
        this.projectColumnPermission = projectColumnPermission;
    }

    public int getProjectRole() {
        return projectRole;
    }

    public void setProjectRole(int projectRole) {
        this.projectRole = projectRole;
    }

    public boolean isOpManagementMembers() {
        return opManagementMembers;
    }

    public void setOpManagementMembers(boolean opManagementMembers) {
        this.opManagementMembers = opManagementMembers;
    }

    public boolean isOpOtherMembers() {
        return opOtherMembers;
    }

    public void setOpOtherMembers(boolean opOtherMembers) {
        this.opOtherMembers = opOtherMembers;
    }

    public boolean isGroupLeader() {
        return groupLeader;
    }

    public void setGroupLeader(boolean groupLeader) {
        this.groupLeader = groupLeader;
    }

    public boolean isContactCreditor() {
        return contactCreditor;
    }

    public void setContactCreditor(boolean contactCreditor) {
        this.contactCreditor = contactCreditor;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getCancel() {
        return cancel;
    }

    public void setCancel(String cancel) {
        this.cancel = cancel;
    }

    public int getCourtHoldingResult() {
        return courtHoldingResult;
    }

    public void setCourtHoldingResult(int courtHoldingResult) {
        this.courtHoldingResult = courtHoldingResult;
    }

    public int getMeeting() {
        return meeting;
    }

    public void setMeeting(int meeting) {
        this.meeting = meeting;
    }

    public int getVote() {
        return vote;
    }

    public void setVote(int vote) {
        this.vote = vote;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public boolean isGrouped() {
        return grouped;
    }

    public void setGrouped(boolean grouped) {
        this.grouped = grouped;
    }

    public int getMemberTotal() {
        return memberTotal;
    }

    public void setMemberTotal(int memberTotal) {
        this.memberTotal = memberTotal;
    }

    public int getJoinMeeting() {
        return joinMeeting;
    }

    public void setJoinMeeting(int joinMeeting) {
        this.joinMeeting = joinMeeting;
    }

    public int getMeetingVote() {
        return meetingVote;
    }

    public void setMeetingVote(int meetingVote) {
        this.meetingVote = meetingVote;
    }

    public int getQuitMeeting() {
        return quitMeeting;
    }

    public void setQuitMeeting(int quitMeeting) {
        this.quitMeeting = quitMeeting;
    }

    public Auth getAuth() {
        return auth;
    }

    public void setAuth(Auth auth) {
        this.auth = auth;
    }

    public int getDoVote() {
        return doVote;
    }

    public void setDoVote(int doVote) {
        this.doVote = doVote;
    }

    public String getResultId() {
        return resultId;
    }

    public void setResultId(String resultId) {
        this.resultId = resultId;
    }

    public int getResultStatus() {
        return resultStatus;
    }

    public void setResultStatus(int resultStatus) {
        this.resultStatus = resultStatus;
    }

    public List<ProVoteFile> getFiles() {
        return files;
    }

    public void setFiles(List<ProVoteFile> files) {
        this.files = files;
    }

    public List<ProVoteVoterGroup> getGroups() {
        return groups;
    }

    public void setGroups(List<ProVoteVoterGroup> groups) {
        this.groups = groups;
    }

    public List<ProVoteVoterMyGroup> getGroupInfo() {
        return groupInfo;
    }

    public void setGroupInfo(List<ProVoteVoterMyGroup> groupInfo) {
        this.groupInfo = groupInfo;
    }

    public static List<ProVote> parse(JsonArray arr) {
        List<ProVote> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            list.add(parse(arr.get(i).getAsJsonObject()));
        }
        return list;
    }

    public static ProVote parse(JsonObject obj) {
        ProVote bean = new Gson().fromJson(obj, ProVote.class);
        return bean;
    }
}
